<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="https://cdn.staticfile.org/vue/2.4.2/vue.min.js"></script>
    <style>
 .component-fade-enter-active, .component-fade-leave-active {
  transition: opacity .3s ease;
}
.component-fade-enter, .component-fade-leave-to
/* .component-fade-leave-active for below version 2.1.8 */ {
  opacity: 0;
}
    </style>
</head>

<body>
    <div id="app">
        <!-- <button v-if="view==='v-b'" @click="view='v-a'">A</button>
        <button v-else   @click="view='v-b'">B</button> -->
        <button  @click="view='v-a'">A</button>
        <button  @click="view='v-b'">B</button>
            <transition name="component-fade" mode="out-in">
             <component v-bind:is="view"></component>
              </transition>
    </div>
    <script>
        new Vue({
  el: '#app',
  data: {
    view: 'v-a'
  },
  components: {
    'v-a': {
      template: '<div>Component A</div>'
    },
    'v-b': {
      template: '<div>Component B</div>'
    }
  }
})
    </script>
</body>

</html>